package com.ygqh.baby.controller.admin;


import com.ygqh.baby.ao.Message;
import com.ygqh.baby.ao.ResponseEntity;
import com.ygqh.baby.handler.HolidayNoticeHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.Map;

@Controller
@RequestMapping("/admin/basePage")
public class BasePageController extends BaseController<Object, Long> {

    @Autowired
    private HolidayNoticeHandler holidayNoticeHandler;

    @RequestMapping("setHolidayNotice")
    @ResponseBody
    public Message setHolidayNotice(String imgUrl, Date startDate, Date endDate) {
        ResponseEntity responseEntity = holidayNoticeHandler.setHolidayNotice(imgUrl, startDate, endDate, getSession().getTrueName());
        return responseEntity.converter();
    }

    @RequestMapping("getHolidayNotice")
    @ResponseBody
    public Message getHolidayNotice() {
        Map holidayNotice = holidayNoticeHandler.getHolidayNotice(false);
        return Message.success(holidayNotice);
    }

    @RequestMapping("delHolidayNotice")
    @ResponseBody
    public Message delHolidayNotice() {
        ResponseEntity responseEntity = holidayNoticeHandler.delHolidayNotice();
        return responseEntity.converter();
    }
}
